import {everyDayNew,canttenId} from "./http/api"
App({
  getOrderStatusArr(){
   
    const orderStatus = [
      "未支付",
      "已确认",
      "已支付",
      "已关闭",
      "已取消",
      "进行中",
      "已完成",
      "已退款",
      "退款中",

    ]
    return orderStatus

   //0-未支付   1-已确认 2-已支付 3-已关闭  4-已取消  5-进行中  6-完成  7-已退款 
  },

  getSonOrderStatusArr(){
    //0-未配送 1-已送达 2-已核销 3-暂停配送 4-已退款 5-已顺延
    const orderStatus = [
      "未配送",
      "已送达",
      "已核销",
      "暂停配送",
      "已退款",
      "已顺延",
    ]
    return orderStatus

   //0-未支付   1-已确认 2-已支付 3-已关闭  4-已取消  5-进行中  6-完成  7-已退款 
  },
  getCartData(){
    const goodsArr = wx.getStorageSync('cart');
    // const goodsArr = JSON.parse(wx.getStorageSync('cart'));
    return goodsArr
  },
  clearOrderStorageSync(){
    wx.removeStorageSync('key');
  },
  
  updateCartData(){

  },

  checkIsLogin(){
    if(!wx.getStorageSync('id')){
      wx.navigateTo({
        url: '/pages/user/authorize/index',
      })
    }
  },


  //用户消息订阅（包月商家确认）
  userSubscribeMessageMonthConfirm(){
    let tmplIds = ['924GvRHTNw6z7LtLbWiMb6wQedP2aXNfeS7FyZcuMug']

    wx.requestSubscribeMessage({
      tmplIds: tmplIds,
      success: (res) => {
        // wx.showToast({
        //   title: '订阅消息 成功',
        // })
      },
      fail: (errCode, errMessage) => {
        // wx.showToast({
        //   title: '订阅消息 错误',
        // })
        // console.log(errCode, errMessage);
      },
      complete: (errMsg) => {
      }

    });
  },

  //用户消息订阅（外卖送达）
  userSubscribeMessageTakeoutReceive(){
    let tmplIds = ['924GvRHTNw6z7LtLbWiMb6wQedP2aXNfeS7FyZcuMug']

    wx.requestSubscribeMessage({
      tmplIds: tmplIds,
      success: (res) => {
        // wx.showToast({
        //   title: '订阅消息 成功',
        // })
      },
      fail: (errCode, errMessage) => {
        // wx.showToast({
        //   title: '订阅消息 错误',
        // })
        // console.log(errCode, errMessage);
      },
      complete: (errMsg) => {
      }

    });
  },

  //外卖员消息订阅
  staffSubscribeMessageNewOrder(){
    let tmplIds = ['hOVaE5-SSs3mbaJx1pimxuv7MkBY4z_b6pSiRXyPSfA']

    wx.requestSubscribeMessage({
      tmplIds: tmplIds,
      success: (res) => {
        // wx.showToast({
        //   title: '订阅消息 成功',
        // })
      },
      fail: (errCode, errMessage) => {
        // wx.showToast({
        //   title: '订阅消息 错误',
        // })
        // console.log(errCode, errMessage);
      },
      complete: (errMsg) => {
      }

    });
  },

  //商家消息订阅(新订单)
  shopSubscribeMessageNewOrder(){
    let tmplIds = ['hOVaE5-SSs3mbaJx1pimxuv7MkBY4z_b6pSiRXyPSfA']

    wx.requestSubscribeMessage({
      tmplIds: tmplIds,
      success: (res) => {
        // wx.showToast({
        //   title: '订阅消息 成功',
        // })
      },
      fail: (errCode, errMessage) => {
        // wx.showToast({
        //   title: '订阅消息 错误',
        // })
        // console.log(errCode, errMessage);
      },
      complete: (errMsg) => {
      }

    });
  },

  getMerchantId(){
    wx.showLoading()
    canttenId().then(res=>{
      if(res.data.code===200){
        wx.setStorageSync('merchantId', res.data.data)
      }

    })
  },





  globalData: {
    // baseUrl:'https://266k745z96.yicp.fun'
    baseUrl:'https://cloud.quwk.cn/canteenapi'
    
  },
  onLaunch() {  
    this.getMerchantId()
  },
})